package com.jindianjichi.basic.service.impl;

import com.jindianjichi.basic.entity.SubjectInfo;
import com.jindianjichi.basic.mapper.SubjectInfoDao;
import com.jindianjichi.basic.service.SubjectInfoService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;

/**
 * 题目信息表(SubjectInfo)表服务实现类
 *
 * @author makejava
 * @since 2024-11-25 10:46:29
 */
@Service
public class SubjectInfoServiceImpl implements SubjectInfoService {
    @Resource
    private SubjectInfoDao subjectInfoDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public SubjectInfo queryById(Long id) {
        return this.subjectInfoDao.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param subjectInfo 筛选条件
     * @return 查询结果
     */
    @Override
    public List<SubjectInfo> queryByPage(SubjectInfo subjectInfo,Integer start, Integer pageSize,Long categoryId,Long labelId) {
        return this.subjectInfoDao.queryAllByLimit(subjectInfo,start,pageSize,categoryId,labelId);
    }

    /**
     * 新增数据
     *
     * @param subjectInfo 实例对象
     * @return 实例对象
     */
    @Override
    public SubjectInfo insert(SubjectInfo subjectInfo) {
        this.subjectInfoDao.insert(subjectInfo);
        return subjectInfo;
    }

    /**
     * 修改数据
     *
     * @param subjectInfo 实例对象
     * @return 实例对象
     */
    @Override
    public SubjectInfo update(SubjectInfo subjectInfo) {
        this.subjectInfoDao.update(subjectInfo);
        return this.queryById(subjectInfo.getId());
    }

    @Override
    public int countByCondition(SubjectInfo subjectInfo, Long categoryId, Long labelId) {
        return subjectInfoDao.countByCondition(subjectInfo,categoryId, labelId);
    }

    @Override
    public List<SubjectInfo> getContributeList() {
        return subjectInfoDao.getContributeList();
    }


}
